/*
 * @Description: 个人资料
 * @Author: iamsmiling
 * @Date: 2021-05-27 22:11:36
 * @LastEditTime: 2021-06-14 17:01:08
 */
import 'package:credit_business_circle/R/R.dart';
import 'package:credit_business_circle/domain/local/list_tile_entity.dart';
import 'package:credit_business_circle/domain/remote/user/user_profile_entity.dart';
import 'package:credit_business_circle/pages/mine/children/profile/profile_controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class ProfilePage extends GetView<ProfileController> {
  const ProfilePage({Key? key}) : super(key: key);

  final double bubbleHeight = 190;
  final double bubbleWidth = 154;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("个人资料"),
        ),
        body: Container(
            child: Column(children: [
          Expanded(
            child: ListView(
              shrinkWrap: true,
              children: [
                for (UserProfileFieldEntity item in controller.fileds)
                  Container(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Container(
                            decoration: BoxDecoration(
                              color: R.color.fff3f3f3,
                            ),
                            padding: EdgeInsets.symmetric(
                                vertical: R.dimen.dp10,
                                horizontal: R.dimen.dp15),
                            child: Text(
                              "${item.label}",
                              style: TextStyle(
                                  fontSize: R.dimen.sp16,
                                  color: R.color.ff111111,
                                  fontWeight: FontWeight.w600),
                            )),
                        for (ListTileEntity tile in item.tiles)
                          GestureDetector(
                            behavior: HitTestBehavior.translucent,
                            onTap: tile.onTap,
                            child: Container(
                              color: R.color.ffffffff,
                              child: Container(
                                decoration: BoxDecoration(
                                    border: Border(
                                        bottom: BorderSide(
                                            width: .5,
                                            color: R.color.ffe5e5e5))),
                                margin: EdgeInsets.symmetric(
                                    horizontal: R.dimen.dp15),
                                padding: EdgeInsets.symmetric(
                                    vertical: R.dimen.dp18),
                                child: Row(
                                  children: [
                                    Text(
                                      tile.label,
                                      style: TextStyle(
                                          fontSize: R.dimen.sp16,
                                          color: R.color.ff222222),
                                    ),
                                    Spacer(),
                                    tile.trailingWidget == null
                                        ? SizedBox.shrink()
                                        : tile.trailingWidget!,
                                    Visibility(
                                      visible: tile.value.isNotEmpty,
                                      child: Text(
                                        tile.value,
                                        style: TextStyle(
                                            fontSize: R.dimen.sp16,
                                            color: R.color.ff555555),
                                      ),
                                    ),
                                    Visibility(
                                      child: Text(
                                        tile.hint,
                                        style: TextStyle(
                                            fontSize: R.dimen.sp16,
                                            color: R.color.ff999999),
                                      ),
                                      visible: tile.value.isEmpty &&
                                          tile.trailingWidget == null,
                                    ),
                                    Visibility(
                                        visible: tile.enabled,
                                        child: Container(
                                            margin: EdgeInsets.only(
                                                left: R.dimen.dp10),
                                            child: Image.asset(R.image.next))),
                                  ],
                                ),
                              ),
                            ),
                          ),
                      ],
                    ),
                  ),
              ],
            ),
          ),
          Container(
            margin: EdgeInsets.only(bottom: Get.mediaQuery.padding.bottom),
            // height: R.dimen.dp98 + Get.mediaQuery.padding.bottom,
            padding: EdgeInsets.only(
                left: R.dimen.dp15, right: R.dimen.dp15, bottom: R.dimen.dp13),
            decoration: BoxDecoration(color: R.color.fff5f5f5),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.end,
              children: [
                Container(
                  margin:
                      EdgeInsets.only(top: R.dimen.dp30, bottom: R.dimen.dp15),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text(
                        "资料完善度",
                        style: TextStyle(
                            fontSize: R.dimen.sp15, color: R.color.ff333333),
                      ),
                      Text(
                        "68%",
                        style: TextStyle(
                            fontWeight: FontWeight.w600,
                            color: R.color.ff13b284,
                            fontSize: R.dimen.sp18),
                      )
                    ],
                  ),
                ),
                Stack(
                  children: [
                    Container(
                      width: R.dimen.width - R.dimen.dp15 * 2,
                      height: R.dimen.dp12,
                      decoration: BoxDecoration(
                          color: R.color.ffdddddd,
                          borderRadius: BorderRadius.circular(R.dimen.sp6)),
                    ),
                    Container(
                      width: (R.dimen.width - R.dimen.dp15 * 2) * .68,
                      height: R.dimen.dp12,
                      decoration: BoxDecoration(
                          gradient: LinearGradient(
                              colors: [R.color.ff22c679, R.color.ff05a073]),
                          borderRadius: BorderRadius.circular(R.dimen.sp5)),
                    ),
                  ],
                ),
              ],
            ),
          ),
        ])));
  }
}
